package com.test.personalblogproject.controller;

import com.test.personalblogproject.pojo.Result;
import com.test.personalblogproject.service.FavoritesItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("favoritesItem")
@Api(tags="在列表里添加东西")
public class FavoritesItemController {
    @Autowired
    private FavoritesItemService favoritesItemService;

    @ApiOperation("添加文章到list")
    @PostMapping("saveArticleToList")
    public Result saveArticleToList(@RequestParam("articleId")Long articleId,@RequestParam("collectionId")Long collectionId){
        return favoritesItemService.saveArticleToList(articleId,collectionId);

    }
    @ApiOperation("取消文章的收藏")
    @PostMapping("unbookmarkTtheArticle")
    public Result unbookmarkTtheArticle(@RequestParam("articleId")Long articleId){
        return favoritesItemService.unbookmarkTtheArticle(articleId);
    }

    @ApiOperation("查看文章是否被收藏")
    @PostMapping("CheckIfTheArticleIsSaved")
    public Result CheckIfTheArticleIsSaved(@RequestParam("articleId")Long articleId){
        return favoritesItemService.CheckIfTheArticleIsSaved(articleId);
    }
    @ApiOperation("看所属收藏列表下的文章" )
    @PostMapping("viewArticlesUnderTheCollectionList")
    public Result viewArticlesUnderTheCollectionList(@RequestParam("collectionId")Long collectionId){
        return  favoritesItemService.viewArticlesUnderTheCollectionList(collectionId);

    }

}
